﻿namespace Numbrella.Client.Common
{
	using System;
	using System.Globalization;
	using System.Windows.Controls;

	public class TimeoutValidationRule : ValidationRule
	{
		public override ValidationResult Validate(object value, CultureInfo cultureInfo)
		{
			double doubleValue;
			bool isDouble = Double.TryParse(value as string, out doubleValue);
			if (!isDouble || doubleValue <= 0)
				return new ValidationResult(false, "Timeout should be non-negative value.");
			return ValidationResult.ValidResult;
		}
	}
}